function Error() {
    this.errors = [];
    var me = this;
    this.addError = function(messageLabelKey, errorField) {
        var msg = messageLabelKey;
        this.errors.push(new ErrorItem(msg, errorField));
    };

    this.hasError = function(){
        return this.errors.length > 0;
    };

    this.messages = function(){
        var msgs = this.errors.select(function(item){
            return item.errorMessage;
        });
        return msgs.unique();
    };

    this.join = function(anotherError){
        anotherError.errors.foreach(function(error){
            me.errors.push(new ErrorItem(error.errorMessage, error.errorField));
        });
    };
}
function ErrorItem(errorMessage, errorField){
    this.errorMessage = errorMessage;
    this.errorField = errorField;
}
